#!/bin/sh

## Check config.param
if [ -f ./config.param ]
then
	## Set PATH
	if [ -f ./config.path ]
	then
		PATHCONTENT=$(cat ./config.path)
		PATHS=$(echo "$PATHCONTENT" | tr ":" "\n")
		
		## Exclude duplicate
		for path in $PATHS
		do
			[ "${PATH#*$path}" = "$PATH" ] && eval export PATH=\"$path:$PATH\"
		done
	fi

	## Print PATH
	echo "INFO - PATH:"
	echo "PATH=$PATH"
	echo ""

	## Print config.param
	echo "INFO - config.param:"
	cat ./config.param
	echo ""

	## Run ./configure
	< ./config.param xargs ./configure "$@"
else
	echo "No config.param file found"
	echo "Please run ./configure or read the readme/README_COMPILATION.md file"
fi
